package com.practice.zookeeper.client;

import com.practice.zookeeper.client.zk.IServiceDiscovery;
import com.practice.zookeeper.client.zk.ServiceDiscoveryImpl;
import com.practice.zookeeper.server.RpcService;
import com.practice.zookeeper.server.zk.ZKConfig;

public class ClientDemo {
	
	public static void main(String[] args) throws InterruptedException {
		IServiceDiscovery discovery = new ServiceDiscoveryImpl(ZKConfig.CONNECT_STR);
		
		RpcClientProxy client = new RpcClientProxy(discovery);
		
//		RpcService service = client.createProxy(RpcService.class, null); //v1.0调用
		
//		RpcService service = client.createProxy(RpcService.class, "2.0"); //v2.0调用
//		
//		System.out.println(service.sayHello("Rpc Client test"));
		
		//模拟集群，利用随机负载均衡随机访问
		for (int i = 0; i < 10; i++) {
			RpcService service = client.createProxy(RpcService.class, null);
			System.out.println(service.sayHello("Rpc Client test"));
			Thread.sleep(1000);
		}
	}

}
